package com.truckdispatching.image;

import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Message;

public abstract class ImageTaskHandler extends Handler implements ImageTaskListener {

	public static final int LOAD_SUCESS = 1;
	public static final int LOAD_FAIL = 2;

	@Override
	public void handleMessage(Message msg) {
		try {
			switch (msg.what) {
			case LOAD_SUCESS: {
				Object[] objs = (Object[]) msg.obj;
				ImageTask task = (ImageTask) objs[0];
				Bitmap bitmap = (Bitmap) objs[1];
				success(task, bitmap);
				break;
			}
			case LOAD_FAIL: {
				ImageTask task = (ImageTask) msg.obj;
				fail(task);
				break;
			}
			default:
				break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
